package bitwiseOperation;

//https://leetcode.cn/problems/is-unique-lcci/description/
public class l_interview_0101 {
    public boolean isUnique(String astr) {
        if(astr.length() > 26) return false;
        int bitMap = 0;
        for(int i = 0; i < astr.length(); i++)
        {
            int ch = astr.charAt(i);
            if(((bitMap >> (ch - 'a')) & 1) != 0) return false; //查看位图某一位
            bitMap = (bitMap | (1 << (ch - 'a'))); //更改位图某一位为1
        }
        return true;
    }
}
